package com.learn.sunday.auth.bean;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.Column;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

@Data
@Table(name ="viid_user")
public class User  implements UserDetails {

    @Column(name = "ID")
    private Integer id;

    @Column(name = "USERNAME")
    private String username;

    @Column(name = "PASSWORD")
    private String password;

    /**
     * 用户类别： 0、管理用户 1、系统用户
     */
    @Column(name = "TYPE")
    private Short type;

    @Column(name = "REALM")
    private String realm;

    @Column(name = "REGISTER_DATETIME")
    private Date registerDate;

    @Column(name = "UPDATE_TIME")
    private Date updateDate;




    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return new ArrayList<>();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
